package com.tencent.backstage.aspect;
import com.tencent.backstage.enums.ResultEnum;
import com.tencent.backstage.utils.ResultVOUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by yhn on 2017/9/12.
 */
@Aspect
@Configuration
@Slf4j
public class AdminAuthorizeAspect {
    @Autowired
    private StringRedisTemplate template;
    @Pointcut("execution(public * com.tencent.backstage.controller.*.*(..))&&"+"!execution(public * com.tencent.backstage.controller.IndexController.login*(..))")
    public void verify(){} //验证
    @Before("verify()")
    public void doverify(){    //方法的具体实现
//        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        String user = (String) attributes.getRequest().getSession().getAttribute("sessionId");
//        if(user == null) {
//            log.info("-------------没有登录-------------");
//            return new ModelAndView("/login_two_columns");
//        }
//        System.out.println(attributes.getRequest().getServletPath());
//       return new ModelAndView(attributes.getRequest().getServletPath());
    }
}
